/*
 * ImageUtil.h
 *
 *  Created on: Jul 12, 2009
 *      Author: kurt
 */

#ifndef IMAGEUTIL_H_
#define IMAGEUTIL_H_

#include <string>
#include <stdint.h>
#include <GL/gl.h>
#include <SDL/SDL.h>
#include <SOIL/SOIL.h>

namespace objdraw 
{
class Image;
class DrawingCanvas;
class ImageUtil 
{
	public:
		
		typedef enum __PixelFormat
		{
			rgb = SOIL_LOAD_RGBA,
			rgba = SOIL_LOAD_RGBA,
		} PixelFormat;
		
//		typedef short PixelFormat;
		
		static int getNextPower2(int width);
		static bool IsPower2(int x);

		static bool is_png(std::string file);
		static bool is_png(SDL_RWops * fp);
		
		static Image * loadImageFile(std::string file, DrawingCanvas * canvas = NULL);
		static Image * loadImageFile(std::string file, PixelFormat pixelFormat, DrawingCanvas * canvas = NULL);
		
		static Image * loadImageFilePNG(std::string file, PixelFormat pixelFormat = rgba, DrawingCanvas * canvas = NULL);
		static Image * loadImageFilePNG(SDL_RWops * fp, PixelFormat pixelFormat = rgba, DrawingCanvas * canvas = NULL);
		
		/** convert and image format */
		static Image * convertImageTo(Image * image, PixelFormat pixelFormat);
};

}

#endif /* IMAGEUTIL_H_ */
